﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

public partial class Customer_Register : System.Web.UI.Page
{
    CustormerMethord CM = new CustormerMethord();
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btnRegister_Click(object sender, EventArgs e)
    {
        bool check = false;
        DataTable dt = new DataTable();
        dt = CM.CheckRegister();
        for (int i = 0; i < dt.Rows.Count; i++)
        {
            if (txtUserName.Text == dt.Rows[i][0].ToString())
            {                
               check = false;
                break;
            }
            else {
                check = true;
            }
        }
        if (check)
        {
            bool restur = CM.CustomerRegister(txtUserName.Text, txtPassword.Text, txtFullName.Text, Convert.ToDateTime(txtBirthday.Text), dlGender.SelectedItem.Text, Convert.ToInt32(txtPhone.Text), txxtAddress.Text, txtEmail.Text);
            if (restur)
            {
                lblMsg.Text = "RESGIER SUCCESSFUll";
            }
            else
            {
                lblMsg.Text = "Register Unsuccessfull";
            }
        }
        else {
            lbluse.Text = "UserName already in use";
        }
        
    }
  
    protected void btnReset_Click(object sender, EventArgs e)
    {
        txtBirthday.Text = "";
        txtEmail.Text = "";
        txtFullName.Text = "";
        txtPassword.Text = "";
        txtPhone.Text = "";
        txtUserName.Text = "";
        txxtAddress.Text = "";
        dlGender.SelectedValue = "0";
    }
    protected void btnCancel_Click(object sender, EventArgs e)
    {
        Response.Redirect("Home.aspx");
    }
}